package com.xmut.mall.store.controller;

import com.xmut.mall.store.annotation.CheckJwt;
import com.xmut.mall.store.dto.*;
import com.xmut.mall.store.entity.StoreDetailEntity;
import com.xmut.mall.store.service.StoreDetailService;
import com.xmut.mall.store.utils.RespBean;
import org.aspectj.apache.bcel.generic.ClassGen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("store/storedetail")
public class StoreDetailController {

    @Autowired
    private StoreDetailService storeDetailService;

    /**
     * 获取商家售后收件地址
     * @param storeId
     * @return
     */
    @CheckJwt
    @GetMapping("/getStoreAfterSaleAddress/{storeId}")
    public RespBean getStoreAfterSaleAddress(@PathVariable Long storeId){
        return storeDetailService.getStoreAfterSaleAddress(storeId);
    }

    /**
     * 申请店铺第一步-填写企业信息
     * @return
     */
    @CheckJwt
    @PostMapping("/applyFirst")
    public RespBean applyFirst(@RequestBody StoreCompanyDTO dto){
        return storeDetailService.applyFirst(dto);
    }

    /**
     * 申请店铺第二步-填写银行信息
     * @return
     */
    @CheckJwt
    @PostMapping("/applySecond")
    public RespBean applySecond(@RequestBody StoreBankDto dto){
        return storeDetailService.applySecond(dto);
    }

    /**
     * 申请店铺第三步-完善其他信息
     * @param dto
     * @return
     */
    @CheckJwt
    @PostMapping("/applyThird")
    public RespBean applyThird(@RequestBody StoreOtherInfoDTO dto){
        return storeDetailService.applyThird(dto);
    }

    /**
     * 更id获取商铺详细信息
     * @param id
     * @return
     */
    @CheckJwt
    @GetMapping("/getStoreDetail/{id}")
    public RespBean getStoreDetail(@PathVariable Long id){
        return storeDetailService.getStoreDetail(id);
    }

    /**
     * 编辑商铺信息
     * @param id
     * @param dto
     * @return
     */
    @CheckJwt
    @PutMapping("/editShop/{id}")
    public RespBean editShop(@PathVariable Long id, @RequestBody StoreEditDTO dto){
        return storeDetailService.editShop(id,dto);
    }

    /**
     * 管理员添加商铺
     * @param dto
     * @return
     */
    @CheckJwt
    @PostMapping("/saveShop")
    public RespBean saveShop(@RequestBody AdminStoreApplyDTO dto){
        return RespBean.success("添加成功");
    }

    /**
     * 管理端审核商铺信息 进行通过 或 驳回
     * @param shopId
     * @param status
     * @return
     */
    @CheckJwt
    @PutMapping("/auditShop/{shopId}/{status}")
    public RespBean auditShop(@PathVariable Long shopId,@PathVariable String status){
        return storeDetailService.auditShop(shopId,status);
    }
}
